﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Input.Dao;
using Shpm.App.Input.Bean;
using Shpm.System.Db;
using Shpm.System;
using Shpm.App.Commons.Db.Beans.Inp;
using Shpm.System.Web.Control;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.App.Master.Dao;
using Shpm.App.Commons.Utils;
using log4net;
using Shpm.System.Validator;

public partial class App_Input_HealthLifeAdviceForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            // 取得当前登录的医生id信息
            SysUserManager manager = new SysUserManager(Context);
            SysUserBean sysUserBean = manager.getSysUserBean();
            MstSysUserBean mstSysUserBean =
                sysUserBean == null ? null : sysUserBean.getMstSysUserBean();
            MstEmployeeBean mstEmpBean =
                sysUserBean == null ? null : sysUserBean.getEmployeeBean();
            string loginId = mstSysUserBean == null ? "" : mstSysUserBean.SysUserId;
            string emplyId = mstSysUserBean == null ? "" : mstSysUserBean.EmployeeId;
            string emplyJob = mstSysUserBean == null ? "" : mstEmpBean.EmployeeJob;
            string emplyLevel = mstSysUserBean == null ? "" : mstEmpBean.EmployeeLevel;
            string emplyRole = mstEmpBean == null ? "" : mstEmpBean.Role;
            ViewState["DOCTOR_ID"] = emplyId;
            ViewState["MEMBER_NO"] = (string)Request.QueryString["MEMBER_NO"];
        }
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        HealthDietAdviceBean paramBean = new HealthDietAdviceBean();
        MemberSrhBean bean = new MemberSrhBean();
        HealthDietAdviceDao dao = new HealthDietAdviceDao();
        MemberSrhDao dao1 = new MemberSrhDao();
        paramBean.MemberNo = Convert.ToString(ViewState["MEMBER_NO"]);

        // edit
        paramBean = dao.Load(paramBean);
        if (paramBean != null)
        {
            LblDoctorId.Text = paramBean.DoctorId;
            LblMemberNo.Text = paramBean.MemberNo;
            //LblMemberNo.Text = Convert.ToString(ViewState["MEMBER_NO"]);
            LblMemberName.Text = paramBean.NameC;
            LblSex.Text = paramBean.Sex;
            LblTel.Text = paramBean.Tel;
            LblApartmentNo.Text = paramBean.ApartmentNo;

        }
        
        bean.MemberNo = Convert.ToString(ViewState["MEMBER_NO"]);
        bean = dao1.GetMemberMemo(bean);
        if(bean!=null)
        {
            memo.Text = bean.MemberMemo;
        }

    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        MemberSrhBean bean = new MemberSrhBean();
        MemberSrhDao dao1 = new MemberSrhDao();
        bean.MemberMemo = this.memo.Text;
        bean.MemberNo = Convert.ToString(ViewState["MEMBER_NO"]);
        dao1.UpdMember(bean);
        ((Design_MasterPage)this.Master).InfoMessage =
                          HttpContext.GetGlobalResourceObject(Constants.GLOBAL_RESOURCE_NAME, "I0002").ToString();
    }
}
